use qlda;
go
create proc getQuesByLevel
	@level int
as
	select * from Question where ques_level = @level
go

create proc getCountQuesByLevel
	@level int
as
	select count(*) [count] from Question where ques_level = @level
go

--insert player
create proc insertPlayer
	@pname nvarchar(30),
	@paddress nvarchar(50),
	@gender bit,
	@age int,
	@score int
as
	insert into Player(pname, paddress, gender, age, score) values(@pname, @paddress, @gender, @age, @score)
go

-------------------------------Admin------------------------------
--update
Create procedure GetAdmin
as
	select * from Users
go

--2. ChangePass
create proc changePass
	@username varchar(30),
	@password varchar(10)
as
	update Users
set
	pass = @password
where
	username  = @username
go
--3.lay pass tu username
Create procedure GetAdminByUser
	@username varchar(30)
as
	select * from Users
where
	username  = @username
go
-------------------------------Question------------------------
--1. Get All Question
	Create procedure getAllQuestion
as
	select * from Question
--2. Insert values Question
drop procedure insertQuestion 

	Create procedure insertQuestion
		
		@ques_content nvarchar(250),
		@ans1 nvarchar(60),
		@ans2 nvarchar(60),
		@ans3 nvarchar(60),
		@ans4 nvarchar(60),
		@ques_level int,
		@anstrue nvarchar
	as
	insert into Question values(@ques_content,@ans1,@ans2,@ans3,@ans4,@ques_level,@anstrue)
go
--3. Update Question
	create procedure updateQuestion
		@ques_id int,
		@ques_content nvarchar(250),
		@ans1 nvarchar(60),
		@ans2 nvarchar(60),
		@ans3 nvarchar(60),
		@ans4 nvarchar(60),
		@ques_level int,
		@anstrue nvarchar
 as 
update Question set ques_content=@ques_content,ans1=@ans1,ans2=@ans2,ans3=@ans3,ans4=@ans4,ques_level=@ques_level,anstrue=@anstrue where ques_id=@ques_id

--4. Delete Question
create procedure deleteQuestion
		@ques_id int
as delete from Question where ques_id=@ques_id
select * from Question
delete from Question where ques_id = 2  
--5 Get Question_quesID
create procedure getAllQuestion_quesID
		@ques_id int
as select * from Question where ques_id=@ques_id